/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/idenger">idenger</a> All rights reserved.
 */
package com.idenger.modules.edu.service.enroll;

import java.util.ArrayList;
import java.util.List;

import com.idenger.modules.edu.dao.enroll.EduEnrollDao;
import com.idenger.modules.edu.entity.enroll.EduEnroll;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.idenger.common.persistence.Page;
import com.idenger.common.service.CrudService;

/**
 * 报名记录Service
 * @author 兰正军
 * @version 2017-12-12
 */
@Service
@Transactional(readOnly = true)
public class EduEnrollService extends CrudService<EduEnrollDao, EduEnroll> {

	public EduEnroll get(String id) {
		return super.get(id);
	}
	
	public List<EduEnroll> findList(EduEnroll eduEnroll) {
		return super.findList(eduEnroll);
	}
	
	public EduEnroll getEduEnrollByUserIdAndCourseId(EduEnroll eduEnroll){
		return dao.getEduEnrollByUserIdAndCourseId(eduEnroll);
	}
	
	public Page<EduEnroll> findPage(Page<EduEnroll> page, EduEnroll eduEnroll) {
		return super.findPage(page, eduEnroll);
	}
	
	@Transactional(readOnly = false)
	public void save(EduEnroll eduEnroll) {
		super.save(eduEnroll);
	}
	
	@Transactional(readOnly = false)
	public void delete(EduEnroll eduEnroll) {
		super.delete(eduEnroll);
	}
	@Transactional(readOnly = false)
	public void saveList(List<EduEnroll> list){
		List<EduEnroll> list2 = new ArrayList<>();
		for(EduEnroll eduEnroll :list){
			eduEnroll.preInsert();
			list2.add(eduEnroll);
		}
		dao.saveList(list2);
	}
	
	@Transactional(readOnly = false)
	public void updateEnrollForUserId(String updUserId,String userId){
		dao.updateEnrollForUserId(updUserId, userId);
	}
	
	
	public List<EduEnroll> findUserListForCourseId(EduEnroll eduEnroll){
		return dao.findUserListForCourseId(eduEnroll);
	}
	
	public List<EduEnroll> findUserListForProjectId(EduEnroll eduEnroll){
		return dao.findUserListForProjectId(eduEnroll);
	}
	
	public List<EduEnroll> findListForOrderId(String orderId){
		return dao.findListForOrderId(orderId);
	}
	/***
	 * 根据课程id查询该
	 * @param courseId
	 * @return
	 */
	public EduEnroll findwhethPayCourse(String courseId,String userId){
		return dao.findwhethPayCourse(courseId,userId);
	}
	
	public List<EduEnroll> findwhethPayProject(String projectId,String userId){
		return dao.findwhethPayProject(projectId,userId);
	}
	
	public EduEnroll findEnrollByUserIdAndCourseId(String courseId,String userId){
		return dao.findEnrollByUserIdAndCourseId(courseId, userId);
	}
	
	
	public List<EduEnroll> findEnrollByUserIdAndProjectId(String projectId,String userId){
		return dao.findEnrollByUserIdAndProjectId(projectId, userId);
	}
	 
}